import Vue from "vue";
import VueRouter from "vue-router";
import Layout from "views/Layout";

Vue.use(VueRouter);
const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push (location) {

return originalPush.call(this, location).catch(err => err)

}

/* 
	默认路由 ：全部都能看见 
	动态路由  ： 
 
 */

// 默认路由 
const defaultRouterMap = [
	{
	  path: "/",
	  redirect:"/login",
		hidden:true,
		meta:{
			name:'主页'
		}
	},
	// {
	//   path: "/about",
	//   name: "About",
	//   component: () =>
	//     import(/* webpackChunkName: "about" */ "../views/About.vue")
	// }, 
	{
		  path: "/login",
		   name: "Login",
		  component: ()=>import("views/Login"),
		  hidden:true,
		  meta:{
		  	name:'登录'
		  }
	},
	{
		  path: "/console",
		   name: "Console",
		   redirect:"index",
		   meta:{
		   	name:'控制台',
			icon:'console'
		   },
		  component: Layout,
		  children:[
			  {
				  path:"/index",
				  name:'Index',
				  meta:{
				  	name:'首页'
				  },
				  component:()=>import("views/Console")
			  },
			  ]
	},
]
// 动态路由 
const asyncRouterMap = [
	{
		  path: "/info",
		   name: "Info",
		   
		   meta:{
		   	name:'信息管理',
			icon:'info',
			 system: 'infoSystem',
			 role:['technician']
		   },
		  component:Layout,
		  children:[
			  {
				  path:"/infoIndex",
				  name:'infoIndex',
				  meta:{
				  	name:'信息列表',
					 role:['technician']
				  },
				  component:()=>import("views/Info/index.vue")
			  },
			  {
				  path:"/infoCategory",
				  name:'InfoCategory',
				  meta:{
					name:'信息分类',
					 role:['technician']
				  },
				  component:()=>import("views/Info/category.vue")
			  },
			  {
				  path:"/infoDetailed",
				  name:'InfoDetailed',
				  hidden:true,
				  meta:{
					name:'信息详情',
					 role:['technician']
				  },
				  component:()=>import("views/Info/infoDetailed.vue")
			  },
			  ]
	},
	{
		  path: "/user",
		   name: "User",
		  
		   meta:{
		   	name:'用户管理',
			icon:'user',
			 system: 'userSystem',
			  role:['sale']
		   },
		   component:Layout,
		  children:[
			  {
				  path:"/userIndex",
				  name:'userIndex',
				  meta:{
					name:'用户列表',
					role:['sale']
				  },
				  component:()=>import("views/User/index.vue")
			  },
		  ]
	}
]

const routes = defaultRouterMap;

const router = new VueRouter({
  routes
});

export {router,defaultRouterMap,asyncRouterMap};
